/*
 * To change this template, choose Tools | Templates and open the template in
 * the editor.
 */
package cn.eclass.bean;

import cn.eclass.bean.api.IUserBean;
import cn.eclass.dao.UserDao;
import cn.eclass.entity.UserEntity;
import java.util.List;

/**
 *
 * @author fortruth
 */
public class UserBean implements IUserBean {

    private UserDao userDao = new UserDao();

    @Override
    public UserEntity add(UserEntity user) {
        return userDao.addUser(user);
    }

    @Override
    public boolean checkLoggedin() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public boolean update(UserEntity user) {
        return userDao.update(user);
    }

    @Override
    public boolean delete(int id) {
        return userDao.deleteUser(id);
    }

    @Override
    public UserEntity login(String userName, String psw) {
        return userDao.getUserByName(userName);
    }

    @Override
    public boolean logout() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public UserEntity get(int id) {
        return userDao.getUser(id);
    }

    @Override
    public List<UserEntity> list() {
        return userDao.getList();
    }
    
    @Override
    public UserEntity getByName(String username) {
    	return userDao.getUserByName(username);
    }
}
